package pl.lsierant.j2me.bipacz.notifications.impl;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

import pl.lsierant.j2me.bipacz.notifications.INotification;
import pl.lsierant.j2me.bipacz.notifications.NotificationType;
import pl.lsierant.j2me.bipacz.persistent.DeserializationHelper;
import pl.lsierant.j2me.bipacz.persistent.IPersistent;
import pl.lsierant.j2me.bipacz.persistent.PersistentObjectType;
import pl.lsierant.j2me.bipacz.persistent.SerializationHelper;

/**
 * Null notification object. Does nothing.
 * <p>
 * Singleton - use INSTANCE field.
 */
public class NullNotification implements INotification, IPersistent {
    public static final NullNotification INSTANCE = new NullNotification();

    // singleton
    private NullNotification() {
    }

    public int getNotificationType() {
        return NotificationType.NULL;
    }

    public void run() {
        // FIXME shouldn't do anything
        System.out.println("NullBeep!");
    }

    public void initialize(DataInputStream serializedData) throws IOException {
        new DeserializationHelper(serializedData); // only read version
    }

    public void serialize(DataOutputStream out) throws IOException {
        new SerializationHelper(out, this, 0);// only write version
    }

    public int getPersistentObjectType() {
        return PersistentObjectType.NULL_NOTIFICATION;
    }

    public String toString() {
        return "NullNotification []";
    }

}
